/*
Source : https://leetcode.com/problems/factorial-trailing-zeroes/
Author : nflush@outlook.com
Date   : 2016-07-19
*/

/*
172. Factorial Trailing Zeroes
 ?  

Question Editorial Solution  
 My Submissions 




?Total Accepted: 65016
?Total Submissions: 193622
?Difficulty: Easy



Given an integer n, return the number of trailing zeroes in n!.

Note: Your solution should be in logarithmic time complexity.

Credits:
Special thanks to @ts for adding this problem and creating all test cases.



Subscribe to see which companies asked this question
*/
class Solution
{
public:
    int trailingZeroes(int n)
    {
        int sum = 0;
        for(n /= 5; n > 0; n /= 5) {
            sum += n;
        }
        return sum;
    }
};